//
//  FJChatTopView.swift
//  FruitJuice
//
//  Created by Rui on 2023/12/17.
//

import UIKit
import SwiftEntryKit

class FJChatTopView: UIView {

    private lazy var backButton = c_make_ex(UIButton.self)
        .image("FJ_Profile_back").end()
    private lazy var nameLabel = c_make_ex(UILabel.self)
        .font(19.font_bold).color(.black).end()
    private lazy var moreButton = c_make_ex(UIButton.self)
        .image("FJ_Message_Chat_more").end()
    private lazy var videoButton = c_make_ex(UIButton.self)
        .image("FJ_Message_Chat_call").end()
    
    var backClosure: (() -> Void)?
    var moreClosure: (() -> Void)?
    var videoClosure: (() -> Void)?
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        subviews{
            backButton
            nameLabel
            moreButton
            videoButton
        }
        
        backButton.leading(15).size(30).centerVertically()
        moreButton.trailing(15).size(30).centerVertically()
        videoButton.height(36).width(53).centerVertically()
        videoButton.Trailing == moreButton.Leading - 10
        nameLabel.leading(60).trailing(130).centerVertically()
        
        backButton.addTarget(self, action: #selector(clickBackButton), for: .touchUpInside)
        moreButton.addTarget(self, action: #selector(clickMoreButton), for: .touchUpInside)
        videoButton.addTarget(self, action: #selector(clickVideoButton), for: .touchUpInside)
    }
    
    @objc private func clickBackButton(){
        backClosure?()
    }
    @objc private func clickMoreButton(){
        moreClosure?()
    }
    @objc private func clickVideoButton(){
        videoClosure?()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
}

